<?php 
/*
 * Query Class - PHP Query Class to be used with DBConnector2.
 * Copyright (c) 2009-2011 Simone Lusenti <lusenti.s@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

class Query {
	private $prepared_query = '';
	private $count=0;
	
	function Query($sql, array $parts = array(), $delimiter="'") {
		$this->prepared_query = $sql;
		
    if (!empty($parts)) {
        foreach ($parts as $part) {
            $part = str_replace('\'','\\\'',$part);            
            $part = str_replace('%','\[percent]]',$part);
            
            $this->prepared_query = preg_replace('/%/', "{$delimiter}{$part}{$delimiter}", $this->prepared_query, 1 /*limit*/);
            $this->count++;
        }
        
        $this->prepared_query = str_replace('\[percent]]','%', $this->prepared_query);
    }
		

	}
	
	function get() {
		return $this->prepared_query;
	}
	
}

?>